﻿<?php
require(dirname(__FILE__)."/../inc/common.inc.php");
header("Content-Type:text/html;charset=utf-8"); 
if ($action=="quit"){
	logo('退出登陆');
	unset($_SESSION[$webdb['session_admin']]);
	unset($_SESSION[$webdb['session_admin_id']]);
	refreshto('index.php','注销成功','0.5');
}
if($_POST['login']){
	if($chknumber != $_SESSION['yzImgNum'] || empty($chknumber)){
		showerr('验证码错误');
	 }
	
	 $_SESSION['yzImgNum']='';
	 $username=trim($_POST['username']);
	 $userpass=$_POST['userpass'];
	 if($online=='1'){
	 	set_cookie('loginname',$username,(60*60*24*30));	
	 }
	 
	 
	 
	 $rs = $db->get_one("select * from {$pre}admin where u_name='$username' and u_pass='".md5($userpass)."' and u_or='1'");
	if($rs){
		$_SESSION[$webdb['session_admin']] = $rs['u_name'];
		$_SESSION[$webdb['session_admin_id']] = $rs['u_id'];
		
		logo('用户登录成功',$username,'登录成功'.$_SESSION[$dbname.'jiqima']);
		$_SESSION[$dbname.'jiqima']='';
		$db->query("update {$pre}admin set u_lasttime='$timestamp',u_lastip='$onlineip',u_logincontent=u_logincontent+1 where  u_id='{$rs['u_id']}'   ");
		refreshto('main.php','登陆成功','2');
		exit;
	}else{
		logo('用户登录失败','--',"尝试用户名：{$username},尝试密码：{$userpass}"); 
		showerr('用户名或密码错误');
	}

}
if($_SESSION[$webdb['session_admin']]!=''){
	refreshto('main.php','登陆成功','0.1');
	exit;
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>后台登录 - <?=$webdb['title']?></title>
<link href="css/login.css" rel="stylesheet" rev="stylesheet" type="text/css" media="all" />
<link href="css/demo.css" rel="stylesheet" rev="stylesheet" type="text/css" media="all" />
<script type="text/javascript" src="js/jquery1.42.min.js"></script>
<script type="text/javascript" src="js/jquery.SuperSlide.js"></script>
<script type="text/javascript" src="js/Validform_v5.3.2_min.js"></script>

<script>
$(function(){

$(".i-text").focus(function(){
$(this).addClass('h-light');
});

$(".i-text").focusout(function(){
$(this).removeClass('h-light');
});

$("#username").focus(function(){
 var username = $(this).val();
 if(username=='输入账号'){
 $(this).val('');
 }
});

$("#username").focusout(function(){
 var username = $(this).val();
 if(username==''){
 $(this).val('输入账号');
 }
});


$("#password").focus(function(){
 var username = $(this).val();
 if(username=='输入密码'){
 $(this).val('');
 }
});


$("#safecode").focus(function(){
 var username = $(this).val();
 if(username=='输入验证码'){
 $(this).val('');
 }
});

$("#safecode").focusout(function(){
 var username = $(this).val();
 if(username==''){
 $(this).val('输入验证码');
 }
});



/*$(".registerform").Validform({
	tiptype:function(msg,o,cssctl){
		var objtip=$(".error-box");
		cssctl(objtip,o.type);
		objtip.text(msg);
	},
	ajaxPost:true
});*/

});




</script>
<script>
function reloadcode(){//刷新验证码函数
    var verify = document.getElementById('safecode');
    verify.setAttribute('src', '../inc/yzimg.php?' + Math.random());
}
</script>

</head>

<body>


<div class="header">
  <h1 class="headerLogo"><a title="后台管理系统" target="_blank" href="../"><img alt="logo" src="images/logo1.png"></a></h1>
	<!--<div class="headerNav">
		<a target="_blank" href="../">网站首页</a>		
	</div>-->
</div>

<div class="banner">

<div class="login-aside">
  <div id="o-box-up"></div>
  <div id="o-box-down"  style="table-layout:fixed;">
   <div class="error-box"></div>
   
   <form class="registerform" method="post" action="?">
   <div class="fm-item">
	   <label for="logonId" class="form-label">系统登陆：</label>
	   <input type="text" value="输入账号" onClick="" maxlength="100" id="username" class="i-text"  name="username"  datatype="s4-12" errormsg="用户名至少4个字符,最多12个字符！"  >    
       <div class="ui-form-explain"></div>
  </div>
  
  <div class="fm-item">
	   <label for="logonId" class="form-label">登陆密码：</label>
	   <input type="password"  name="userpass" value="" maxlength="100" id="password" class="i-text" datatype="*5-16" nullmsg="请设置密码！" errormsg="密码范围在6~16位之间！">    
       <div class="ui-form-explain"></div>
  </div>
  
  <div class="fm-item pos-r">
	   <label for="logonId" class="form-label">验证码</label>
	   <input type="text" value="输入验证码" maxlength="100" id="yzm" class="i-text yzm" name="chknumber" nullmsg="请输入验证码！" >    
       <div class="ui-form-explain"><img onClick="javascript:reloadcode();" src="../inc/yzimg.php?<?=rand(100,999)?>" class="yzm-img" id="safecode" /></div>
  </div>
  
  <div class="fm-item">
	   <label for="logonId" class="form-label"></label>
	   <input type="submit"  name="login"  value="&nbsp;" tabindex="4" id="send-btn" class="btn-login"> 
       <div class="ui-form-explain"></div>
  </div>
  
  </form>
  
  </div>

</div>

	<div class="bd">
		<ul>
			<li style="background:url(images/theme-pic1.png) #CCE1F3 center 0 no-repeat;"><a target="_blank" href="#"></a></li>			
		</ul>
	</div>

	<div class="hd"><ul></ul></div>
</div>
<script type="text/javascript">jQuery(".banner").slide({ titCell:".hd ul", mainCell:".bd ul", effect:"fold",  autoPlay:true, autoPage:true, trigger:"click" });</script>


<div class="banner-shadow"></div>

<div class="footer">
   <p><?=$webdb['title']?></p>
</div>
</body>
</html>
